package com.view.imageview;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;

/**
 * Created by Administrator on 2016-12-19.
 */
public abstract class AbsSingleFragmentActivity extends FragmentActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        FragmentManager fm = getSupportFragmentManager();
        Fragment fragment = fm.findFragmentById(R.id.id_fragmentContainer);
        if (fragment == null) {
            fragment = creatFragment();
            fm.beginTransaction().add(R.id.id_fragmentContainer,fragment).commit();
        }
    }

    protected abstract Fragment creatFragment();
    protected abstract int getLayoutId();
}
